Neural ensemble dynamics - how groups of neurons shift between functional groups in real time to optimize neural network performance - represents a clinically important frontier in the study of brain function. Flexible ensemble structure is an inherent feature of many neural circuits, and we speculate that aberrations of such dynamics may contribute importantly to pathology in neurological and psychiatric disease. Unfortunately, technical issues have long hindered investigations of real-time flexibility in network structure. Here we will apply newly developed imaging and data processing tools to study flexible ensemble dynamics in an experimentally tractable model system - the Aplysia locomotion network. The central hypothesis is that Aplysia's locomotion network displays flexible ensemble structures during the course of its stimulus-elicited crawling motor program, which then persist to encode memory. The specific aims are to 1) define the rapid the reorganization of neural ensemble structures that occur during the time course of a single motor program, 2) determine to what extent the network ensembles identified in Aim 1 persist to encode the memory for sensitization, and 3) test the hypothesis that the rapid ensemble reorganization to be characterized in Aims 1 and 2 is mediated by known, intrinsic serotonergic modulatory neurons. The approach will use a powerful combination of large-scale imaging with fast voltage sensitive dyes and three data analysis techniques, including a fully automated spike-sorting method for identifying the neurons in the raw data, and two new-generation unsupervised spike train correlation methods to define and track the functional neuronal ensembles operating during normal network function and learning. The short term goal of this project is to provide a single-neuron resolution view of the moment-to-moment alterations in neural network structures that may be essential to healthy brain function. The long-term goal is to use such information to inform novel treatments for neurological and psychiatric disease.